using System;
using System.DHTML;
using Ext;
using Ext.form;
using Ext.util;

namespace SampleScripts.window {
    public delegate void ElementClickDelegate(EventObject evt, Element el);
    public class HelloScript {
		private WindowClass _win;

        public static void main(Dictionary args) {
			ExtClass.onReady(new AnonymousDelegate(delegate() { new HelloScript().init(); }));
        }

		public void init() {
			Element button = ExtClass.get("show-btn");
            button.on("click", new ElementClickDelegate(ShowWindow));

		}

        private void ShowWindow(EventObject evt, Element el)
		{
			if (_win == null)
			{
				_win = new Ext.WindowClass(new WindowConfig()
					.custom("el", "hello-win")
					.layout("fit")
					.width(500)
					.height(300)
					.closeAction("hide")
					.plain(true)

					.items(new TabPanel(new TabPanelConfig()
						.custom("el", "hello-tabs")
						.custom("autoTabs", true)
						.custom("activeTab", 0)
						.custom("deferredRender", false)
						.border(false)
						.ToDictionary()))

					.buttons(new object[] {
						new ButtonConfig()
							.text("Submit")
							.disabled(true)
							.ToDictionary(),
						new ButtonConfig()
							.text("Close")
							.handler(new DOMEventHandler(delegate { _win.hide(); }))
							.ToDictionary(),
					})

					.ToDictionary());
			}

            _win.show(el);
		}
    }
}
